$(".content .title li").on("click", function () {
    $(this).addClass("bottom").siblings("li").removeClass("bottom")
})
$(".playNew").on("click", function () {
    $(".play-new").show().siblings("div").hide()
})
$(".playHot").on("click", function () {
    $(".play-hot").show().siblings("div").hide()
})
$(".playCate").on("click", function () {
    $(".play-category").show().siblings("div").hide()
})

// 发现酷玩--最新
$.ajax({
    url: "http://127.0.0.1:3000/play/new",
    type: "get",
    success: function (res) {
        // console.log(res);
        for (var j = 0; j < res.length; j++) {
            var newArray = res[j]
            for (var i = 0; i < newArray.length; i++) {
                // console.log(newArray[i]);
                $(".c-play .play-new ul").append(`
                <li>
                    <img src=${newArray[i].img} alt="">
                    <h4>${newArray[i].text}</h4>
                    <p>${newArray[i].description}</p>
                    <div class="liuliang">
                        <div class="name">
                        <h4>${newArray[i].price}</h4>
                        </div>
                        <div class="dianzan">
                            <span>
                                <img src="../img/css/img/xin.png" alt="">
                                ${newArray[i].like}
                            </span>
                            <span>
                                <img src="../img/css/img/reply.png" alt="">
                                ${newArray[i].words}
                            </span>
                        </div>
                    </div>
                </li>
                `)
            }
        }
    }
})
// 发现酷玩--最热
$.ajax({
    url: "http://127.0.0.1:3000/play/hot",
    type: "get",
    success: function (res) {
        // console.log(res);
        for (var j = 0; j < res.length; j++) {
            var newArray = res[j]
            for (var i = 0; i < newArray.length; i++) {
                // console.log(newArray[i]);
                $(".c-play .play-hot ul").append(`
                <li>
                    <img src=${newArray[i].img} alt="">
                    <h4>${newArray[i].text}</h4>
                    <p>${newArray[i].description}</p>
                    <div class="liuliang">
                        <div class="name">
                        <h4>${newArray[i].price}</h4>
                        </div>
                        <div class="dianzan">
                            <span>
                                <img src="../img/css/img/xin.png" alt="">
                                ${newArray[i].like}
                            </span>
                            <span>
                                <img src="../img/css/img/reply.png" alt="">
                                ${newArray[i].words}
                            </span>
                        </div>
                    </div>
                </li>
                `)
            }
        }
    }
})
// 加载更多
// $(".mores").on("click", function () {
//     console.log(1);
//     $(".c-play").css("height", "1300px")
//     $(this).html("没有更多了~").css("color", "#333")
// })

// 品类
$.ajax({
    url: "http://127.0.0.1:3000/play/category",
    type: "get",
    success: function (res) {
        // console.log(res[0]);
        // console.log(res[0].list[0]);
        console.log(res[0].list[0].productName);
        for (var i = 0; i < res[0].list.length; i++) {
            $(".play-category .list ul").append(`
                <li><a href="#">${res[0].list[i].productName} ( <span>${res[0].list[i].nums} )</a></span></li>
            `)
        }
    }
})
// 个人护理
$.ajax({
    url: "http://127.0.0.1:3000/play/category",
    type: "get",
    success: function (res) {
        for (var i = 0; i < res[1].list.length; i++) {
            $(".play-category .person ul").append(`
                <li><a href="#">${res[1].list[i].productName} ( <span>${res[0].list[i].nums} )</a></span></li>
            `)
        }
    }
})
// 健康
$.ajax({
    url: "http://127.0.0.1:3000/play/category",
    type: "get",
    success: function (res) {
        for (var i = 0; i < res[2].list.length; i++) {
            $(".play-category .health ul").append(`
                <li><a href="#">${res[2].list[i].productName} ( <span>${res[0].list[i].nums} )</a></span></li>
            `)
        }
    }
})
// 户外运动
$.ajax({
    url: "http://127.0.0.1:3000/play/category",
    type: "get",
    success: function (res) {
        for (var i = 0; i < res[4].list.length; i++) {
            $(".play-category .out ul").append(`
                <li><a href="#">${res[4].list[i].productName} ( <span>${res[0].list[i].nums} )</a></span></li>
            `)
        }
    }
})